from google.appengine.ext import db
from google.appengine.ext.db import polymodel
from horseanalysis.lib.callable import Callable
from horseanalysis.model.race import Race
from horseanalysis.model.race_batch import RaceBatch

class TwinOdd(polymodel.PolyModel):
  race = db.ReferenceProperty(Race)
  batch_time = db.ReferenceProperty(RaceBatch)
  first_horse_no = db.IntegerProperty()
  second_horse_no = db.IntegerProperty()
  odds = db.FloatProperty()
  
  def create_new_entry(klass, race, batch_time, first_horse_no, second_horse_no, odds):
    entry = klass(race=race, batch_time=batch_time, first_horse_no=first_horse_no, second_horse_no=second_horse_no, odds=odds)
    entry.put()
    
  create_new_entry = Callable(create_new_entry)